/*
 *  Copyright (c)  2016-NOW  Jacars Co.Ltd.
 *  All rights reserved.
 */
package com.jacars.biz.user.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.jacars.biz.user.dao.service.JsptDictService;
import com.jacars.biz.user.dao.mapper.JsptDictMapper;
import com.jacars.biz.user.dao.model.JsptDict;
import com.jacars.biz.user.service.DictService;
import com.jacars.biz.user.vo.JsptDictVO;
import com.jacars.common.service.impl.SuperServiceImpl;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;
import java.util.List;

import static com.jacars.biz.user.cache.CacheNames.DICT_LIST;
import static com.jacars.biz.user.cache.CacheNames.DICT_VALUE;


/**
 * 服务实现类
 *
 * @author Chill
 */
@Service
public class DictServiceImpl extends SuperServiceImpl<JsptDictMapper, JsptDict> implements DictService {

	private final JsptDictService jsptDictServicel;

	public DictServiceImpl(JsptDictService jsptDictServicel) {
		this.jsptDictServicel = jsptDictServicel;
	}

	@Override
	public IPage<JsptDictVO> selectDictPage(IPage<JsptDictVO> page, JsptDictVO dict) {
		return jsptDictServicel.selectDictPage(page, dict);
	}

	@Override
	public List<JsptDictVO> tree() {
		return jsptDictServicel.tree();
	}

	@Override
	@Cacheable(cacheNames = DICT_VALUE, key = "#code+'_'+#dictKey")
	public String getValue(String code, Integer dictKey) {
		return jsptDictServicel.getValue(code, dictKey);
	}

	@Override
	@Cacheable(cacheNames = DICT_LIST, key = "#code")
	public List<JsptDict> getList(String code) {
		return jsptDictServicel.getList(code);
	}

	@Override
	@CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE}, allEntries = true)
	public boolean submit(JsptDict dict) {
		return jsptDictServicel.submit(dict);
	}
}
